package com.codedancer.campus.manager.api.circle;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.codedancer.campus.common.anno.InterfacePermission;
import com.codedancer.campus.common.core.BaseApi;
import com.codedancer.campus.common.response.ApiResponse;
import com.codedancer.campus.manager.api.circle.ro.CircleFollowPageSearchRo;
import com.codedancer.campus.manager.service.ICircleFollowService;
import com.codedancer.campus.manager.service.bo.circle.CircleFollowPageSearchBo;
import com.codedancer.campus.manager.service.vo.circle.CircleFollowPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/circle-follow")
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE,
    RequestMethod.PUT}, maxAge = 3600)
@Api(value = "圈子关注Api", description = "圈子关注Api", tags = "圈子关注Api")
public class CircleFollowApi extends BaseApi {

    @Autowired
    private ICircleFollowService circleFollowService;

    @GetMapping("/page/{circleUuid}")
    @ApiOperation("分页查询某个圈子关注用户列表")
    @InterfacePermission(encodes = {"superAdmin","treeHoleAdmin"})
    public ApiResponse<IPage<CircleFollowPageVo>> page(
        @PathVariable(value = "circleUuid", required = true) @ApiParam(value = "圈子uuid", required = true) String circleUuid,
        @ApiParam(value = "分页查询关注列表Ro", required = false) CircleFollowPageSearchRo circleFollowPageSearchRo) {
        CircleFollowPageSearchBo circleFollowPageSearchBo = BeanUtil
            .copyProperties(circleFollowPageSearchRo, CircleFollowPageSearchBo.class);
        circleFollowPageSearchBo.setCircleUuid(circleUuid);
        return success(circleFollowService.page(circleFollowPageSearchBo));
    }
}
